package com.lagou.tomcat.http;

import java.io.IOException;
import java.io.InputStream;

/**
 * 创建人: yyn
 * 创建时间:2021/9/4 22:39
 */
public class Request {
    private String method;
    private String uri;

    private Request(String method, String uri) {
        this.method = method;
        this.uri = uri;
    }

    public static Request create(InputStream inputStream) {
        try {
            byte[] bytes = new byte[1024];
            inputStream.read(bytes);
            String string = new String(bytes);
            String[] line = string.split("\\n");
            String[] strings = line[0].split(" ");
            return new Request(strings[0], strings[1]);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    public String getMethod() {
        return method;
    }

    public String getUri() {
        return uri;
    }
}
